#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
using namespace std;

class Solution {
public:
    vector<int> exchange(vector<int>& nums) {
        int i = 0;
        int j = nums.size()-1;
        while(i<j){
            if(nums[i]%2!=0){
                i = i+1;
            }
            else{
                //将nums[i]和nums[j]互换
                int temp = nums[i];
                nums[i] = nums[j];
                nums[j] = temp;
                j = j-1;
            }
        }
        return nums;
    }
};

int main(){
    Solution S;
    vector<int> nums = {1,2,3,4};
    vector<int> result = S.exchange(nums);
    return 0;
    }